import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import OtherView from '../views/OtherView.vue'

const routes = [
  {
    path: '/',
    name: 'home-default',
    component: HomeView,
    children: [
      {
        path: '/',
        name: 'home',
        component: () => import('@/views/xiaotao/Home.vue'),
        meta: { title: '首页' }
      },
      {
        path: '/product/list',
        name: 'product',
        component: () => import('@/views/xiaotao/ProductList.vue'),
        meta: { title: '商品列表' }
      },
      {
        path: '/product/add',
        name: 'productAdd',
        component: () => import('@/views/xiaotao/ProductAdd.vue'),
        meta: { title: '新增商品' }
      },
      {
        path: '/coupon/list',
        name: 'couponList',
        component: () => import('@/views/xiaotao/CouponList.vue'),
        meta: { title: '优惠券列表' }
      },
      {
        path: '/coupon/add',
        name: 'couponAdd',
        component: () => import('@/views/xiaotao/CouponAdd.vue'),
        meta: { title: '新增优惠券' }
      },
      {
        path: '/coupon/issue',
        name: 'couponIssue',
        component: () => import('@/views/xiaotao/CouponIssue.vue'),
        meta: { title: '发放优惠券' }
      },
      {
        path: '/order/list',
        name: 'orderList',
        component: () => import('@/views/xiaotao/OrderList.vue'),
        meta: { title: '优惠券列表' }
      },
    ],
  },
  {
    path: '/other',
    name: 'other',
    component: OtherView,
    meta: { title: '其他页面' }
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView.vue'),
    meta: { title: '登录' }
  }
];

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
});

export default router